package abacab.router;

import java.util.Queue;

import abacab.message.Envelope;

/**
 * A simple router to have the messages be handled in a round robin. This version allows an actor to "steal" work from an other one.
 * 
 * @param <M>
 *          the type of handled messages
 */
@SuppressWarnings("rawtypes")
public class RoundRobinRouterShared<M> extends RoundRobinRouter<M> {
	/** The working queue (shared by all children actors) */
	private Queue<Envelope>	queue;

	/**
	 * Create the router
	 * 
	 * @param nbActors
	 *          the number of actors
	 */
	public RoundRobinRouterShared(int nbActors) {
		super(nbActors);
	}

	@Override
	protected Queue<Envelope> createQueueForActor() {
		if (this.queue == null) {
			this.queue = super.createQueueForActor();
		}
		return this.queue;
	}
}